package com.example.take_out_admin.handle;

import com.example.take_out_admin.common.Result;
import com.example.take_out_admin.exceptions.BusinessException;
import com.example.take_out_admin.exceptions.enumetation.ResponseEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class BaseExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result<Object> exceptionHandler(Exception e){
        return  Result.error(ResponseEnum.UNKNOWN_ERROR);

    }
    @ExceptionHandler(BusinessException.class)
    public Result<Object> businessExceptionHandler(BusinessException e) {
        return Result.error(e.getResponse());
    }
}
